<template>
	<div class="table-container">
		<!--默认查询-->
		<exSearch ref="exSearch" v-model="search" @getList="getList">
			<!-- <template v-slot:SysStoreID>
				<el-form-item v-if="user.isAdminStore||user.isMainStore">
					<remoteselect v-model="search.SysStoreID" url="api/System/SysStoreListSelect" value-label="SysStoreName"
						value-key="SysStoreID" query-key="selectIDName" :placeholder="replaceID(keyLan['SysStoreID'])" style="width:150px;">
						<template v-slot="{ row }">
							{{row.SysStoreName}}
						</template>
					</remoteselect>
				</el-form-item>
			</template> -->
		</exSearch>
		<!--默认列表-->
		<exTable ref="exTable" v-model="list" @selection-change="selectionChange"
			:showOp="button.编辑||button.启用禁用||button.删除" :showPage="true">
			<!-- <template v-slot:SysStore.EnumSysStoreType>
				<u-table-column type="selection" width="47"></u-table-column>
				<u-table-column prop="SysStore.EnumSysStoreType" :label="comLan['Key']['SysStore']['EnumSysStoreType']" width="80" align="center">
					<template v-slot="scope">
						<span v-html="getLabel(scope.row.SysStore.EnumSysStoreType,EnumSysStoreType)"></span>
					</template>
				</u-table-column>
			</template> -->
		</exTable>

		<!--默认新建编辑-->
		<exAddEdit ref="exAddEdit" @success="getList"></exAddEdit>
	</div>
</template>

<script>
	import common from "@/common/common.js";
	import js from "./js.js";
	import exAddEdit from "./OrganizationAdd";
	import exSearch from "@/Auto/Organization/OrganizationListSearch.vue";
	import exTable from "@/Auto/Organization/OrganizationListTable.vue";

	export default {
		name: "OrganizationList",
		mixins: [common.baseVM, js],
		components: {
			exAddEdit,
			exSearch,
			exTable,
		},
		data() {
			return {
				button: {
					查询: false,
					新建: false,
					编辑: false,
					启用禁用: false,
					删除: false,
					导出: false
				},
				search: {
					SysStoreID: null,
					Name: null,
					Phone: null,
					Address: null,
					EnumStatus: 1,
					CreateSysEmployeeID: null,
					CreateDate: [],
				},
				isRedict: false
			};
		},
		methods: {
			selectionChange(val) {
				//console.log("selectionChange", val);
			},
			init() {
				this.loadDefaultSearch(() => {
					this.getList();
				});
			},
			btnAdd() {
				if (this.isRedict) {
					// 跳转链接
					var url = "/Organization/OrganizationAddRedict";
					this.navigateToRefresh(url);
				} else {
					this.$refs["exAddEdit"].show();
				}
			},
			btnEdit(scope) {
				if (this.isRedict) {
					// 跳转链接
					var url = "/Organization/OrganizationAddRedict";
					this.navigateToRefresh(url, {
						id: scope.row.OrganizationID
					});
				} else {
					this.$refs["exAddEdit"].show(scope);
				}
			},
			btnEnumStatus(scope, status) {
				var id = scope.row.OrganizationID;
				var name = scope.row.Name;
				var str = status == 1 ? this.comLan["btnEnable"] : this.comLan["btnDisable"];
				var msg = this.stringFormat(this.comLan.js["updateEnumStatus"], name, str);
				this.confirm(msg, () => {
					this.post("api/Organization/UpdateEnumStatus", this.toKeyValue({
						id: id,
						status: status
					})).then(data => {
						this.getList();
					}).catch(error => {});
				});
			},
			btnDel(scope) {
				var id = scope.row.OrganizationID;
				var name = scope.row.Name;
				var msg = this.stringFormat(this.comLan.js["delete"], name);
				this.confirm(msg, () => {
					this.post("api/Organization/Del", this.toKeyValue({
						id: id
					})).then(data => {
						this.getList();
					}).catch(error => {});
				});
			},
			getList() {
				this.getListByUrl('api/Organization/List');
			},
			btnExport() {
				this.$refs.exTable.exportFile(this.keyLan["name"]);
			},
		}
	};
</script>
